<include file="Public/min-header"/>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
    <section class="content">
    <div class="row">
      <div class="col-xs-12">
      	<div class="box">
           <nav class="navbar navbar-default">
			<div class="collapse navbar-collapse">
                <div class="navbar-form pull-right margin">
                    <?php if($order['order_status']!=2){
						?>
                         <a href="{:U('Admin/order/edit_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">修改订单</a>
                      <?php
					  }else{
						  echo '<span style="color:red">已完成订单禁止编辑!</span>';
					  }
					  ?>
                      <!--<if condition="($split eq 1) and ($order['order_status'] lt 2)">
                         <a href="{:U('Admin/order/split_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">拆分订单</a>
                      </if>
                    -->
<!--                      <a href="/index.php/Admin/Order/order_print/order_id/{$order['master_order_sn']}" target="_blank" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="打印订单">
	                     <i class="fa fa-print"></i>打印订单
	                  </a> -->
                      <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
               </div>
            </div>
           </nav>
   
        <!--新订单列表 基本信息-->
        <div class="panel panel-default">
            <if condition="$order.pda_qdzt eq 1 ">
            <div style="margin-left: 20px;font-size: 20px;font-weight: bold;color: #f00">注：只有无货单才可以修改入库时间、出库时间、配送总单号。修改配送总后物流状态会恢复默认</div>
            </if>
            <div class="panel-heading">
                <h3 class="panel-title text-center">基本信息</h3>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <td>订单 ID:</td>
                        <td>订单号:</td>
                        <td>会员:</td>
                        <td>电话:</td>
                        <td>应付:</td>
                        <td>订单 状态:</td>
                        <td>下单时间:</td>
                        <td>支付时间:</td>
                        <td>支付方式:</td>
                    </tr>
                    <tr>
                        <td>{$order.order_id}</td>
                        <td>{$order.order_sn}</td>
                        <td><a href="#" target="_blank">{$order.consignee}</a></td>
                        <td>{$order.mobile}</td>
                        <td>{$order.order_amount}</td>
                        <td id="order-status">{$order_status[$order[order_status]]} / {$pay_status[$order[pay_status]]}<if condition="$order['pay_code'] eq 'cod'"><span style="color: red">(货到付款)</span></if> / {$shipping_status[$order[shipping_status]]}</td>
                    	<td>{$order.add_time|date='Y-m-d H:i',###}</td>
                    	<td><if condition="$order.pay_time neq 0">
                                {$order.pay_time|date='Y-m-d H:i',###}
                         <else/>
                            N
                         </if>
                        </td>
                        <td id="pay-type">
                            {$order.pay_name|default='其他方式'}
                        </td>
                    </tr>
                    <tr> 
                        <td class="text-right" style="line-height:55px;">包装件数：<b style="color: red;">{$order.jian_count}</b> 件</td>
                        <td class="text-left" colspan="8">
							<table class="table table-bordered">
								<tr>
									<th class="text-center" width="130">标签名</th>
									<th class="text-center" width="120">入库设备</th>
									<th class="text-left">入库状态 / 时间</th>
									<th class="text-center" width="120">出库设备</th>
									<th class="text-left">出库状态 / 时间</th>
								</tr>
								<?php
								foreach($order["jian_list"] as $v){
								?>
								<tr>
									<td class="text-center" width="130"><a href="/index.php/Seller/Order/biaoqian_print/order_id/{$order.order_id}" target="_blank">标签 - {$v.chuku_num}</a></td> 
									<td class="text-center" width="150"><?php echo $v[$z.'pda_name_ruku'];?></td>
									<td class="text-left">{:$v[$z.'status_r']!='0'?'<span style="color: green;">已入库</span>':'未入库'} / <?php echo date('Y-m-d H:i',$v[$z.'ruku_time']);?></td>
									<td class="text-center" width="150">{:$v[$z.'pda_name_chuku']}</td>
									<td class="text-left">{:$v[$z.'status_c']!='0'?'<span style="color: green;">已出库</span>':'未出库'} / <?php echo date('Y-m-d H:i',$v[$z.'chuku_time']);?></td>
								</tr>
								<?php
								}
								?>

                                <if condition="$order.pda_qdzt eq 1 ">
                                    <tr>
                                        <td class="text-center" width="130" style="color: #f00">输入后点击空白位置后立刻生效格式xxxx-xx-xx xx:xx</td>
                                        <td class="text-center" width="150">修改入库时间</td>
                                        <td  ><input type="text" id="ruku_last_time" name="ruku_last_time" rel="{$order.order_id}" onblur="edit_time(this,'ruku_last_time')" value="" /></td>
                                        <td class="text-center" width="150">修改出库时间</td>
                                        <td ><input type="text" id="chuku_last_time" name="chuku_last_time"   rel="{$order.order_id}" onblur="edit_time(this,'chuku_last_time')" value="" /></td>
                                    </tr>
                                    <tr>

                                        <td colspan="3" class="text-center" style="color: #f00" width="150">输入配送总单号：</td>
                                        <td colspan="2"><input type="text" id="duizhang_sn" name="duizhang_sn" style="width: 300px;"   rel="{$order.order_id}" onblur="edit_time(this,'duizhang_sn')" value="" /></td>
                                    </tr>
                                </if>
							</table>
						</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!--新订单列表 收货人信息-->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title text-center">收货信息</h3>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <tbody><tr>
					<td>收货人:</td>
					<td>联系方式:</td>
					<td>地址:</td>
					<td>邮编:</td>
					<td>单据备注:</td>
					<td>异常备注:</td>
                    </tr>
                    <tr>
                        <td>{$order.consignee}</td>
                        <td>{$order.mobile}</td>
                        <td>{$order.address2}</td>
                        <td>
                            <if condition="$order.zipcode neq ''">
                                {$order.zipcode}
                                <else/>
                                N
                            </if>
                        </td>
                        <td>
                            {$order.user_note|htmlspecialchars_decode}
                            <!--
                            <if condition="$order[shipping_name]">
                                <a href="{:U('Admin/Order/shipping_print',array('order_id'=>$order['order_id'],'code'=>$order['shipping_code']))}" target="_blank" class="btn btn-primary input-sm" onclick="">打印快递单</a>
                            </if>
                            -->
                        </td>
                        <td class="text-left">{$order.unusual_remake}</td>


                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!--新订单列表 商品信息-->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title text-center">商品信息 </h3>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                    <tr>
						<td class="text-left" style="width: 110px;">图片</td>
                        <td class="text-left">商品</td>
                        <td class="text-left">属性</td>
                        <td class="text-right">数量</td>
<!--                        <td class="text-right">单品价格</td> --> 
                        <td class="text-right">会员折扣价</td>
                        <td class="text-right">单品小计</td>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="orderGoods" id="good">
                        <tr>
							<td class="text-left"><img src="{$good.original_img}" width="90" height="90"/>
						    </td>
                            <td class="text-left">{$good.goods_name}
                            </td>
                            <td class="text-left">{$good.goods_attr}</td>
                            <td class="text-right">{$good.goods_num}</td>
<!--                            <td class="text-right">{$good.goods_price}</td> -->
                            <td class="text-right">{$good.member_goods_price}</td>
                            <td class="text-right">{$good.goods_total}</td>
                        </tr>
                    </volist>

                    <tr>
                        <td colspan="5" class="text-right">小计:</td>
                        <td class="text-right">{$order.goods_price}</td>
                    </tr>
                    </tbody>
                </table>

            </div>
        </div>
<?php
	if(session('role_id')==10 || session('role_id')==15 || session('role_id')==8){}else{
?>
        <!--新订单列表 费用信息-->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title text-center">费用信息
                    <!--
                    <a class="btn btn-primary btn-xs" data-original-title="修改费用" title="" data-toggle="tooltip" href="{:U('Admin/Order/editprice',array('order_id'=>$order['order_id']))}">
                        <i class="fa fa-pencil"></i>
                    </a>
                    -->
                </h3>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <td class="text-right">小计:</td>
                        <td class="text-right">平台费:</td>
                        <td class="text-right">积分 (-{$order.integral}):</td>
                        <td class="text-right">余额抵扣</td>
                        <td class="text-right">优惠券抵扣</td>
                        <td class="text-right">价格调整:</td>
                        <td class="text-center">应付:</td>
                    </tr>
                    <tr>
                        <td class="text-right">{$order.goods_price}</td>
                        <td class="text-right">-{$points_count}</td>
                        <td class="text-right">-{$order.integral_money}</td>
                        <td class="text-right">-{$order.user_money}</td>
                        <td class="text-right">-{$order.coupon_price}</td> 
                        <td class="text-right">减:{$order.discount}</td>
                        <td class="text-center"><b style="color: red;">{:sanwei($order['order_amount']-$points_count)}</b></td>
                    </tr>
					<tr> 
					<td class="text-right" style="font-weight: bold;color: #3c8dbc;">平台改单：</td>
					<td colspan="6" style="color: #3c8dbc;"><if condition="$order.admin_note eq ''">
							<span style="color:#999;">未改单</span>
					<else/>
							<span style="color:red;">{$order.admin_note|htmlspecialchars_decode}</span>
					</if></td>
					</tr>
                    </tbody>
                </table>

            </div>
        </div>
<?php
}
?>
        <!--新订单列表 操作信息-->
<!--        
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title text-center">操作信息</h3>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <div class="row">
                            <td class="text-right col-sm-2"><p class="margin">操作备注：</p></td>
                            <td colspan="3">
                                <form id="order-action">
                                    <textarea name="note" placeholder="请输入操作备注" rows="3" class="form-control"></textarea>
                                </form>
                            </td>
                        </div>
                    </tr>
                    <tr>
                        <div class="row">
                            <td class="text-right col-sm-2"><p class="margin">当前可执行操作：</p></td>
                            <td colspan="3">
                                <div class="input-group">
                                	<foreach name="button" item="vo" key="k">
                                		<if condition="$k eq 'pay_cancel'">
                                			<a class="btn btn-primary margin" href="javascript:void(0)" data-url="{:U('Order/pay_cancel',array('order_id'=>$order['order_id']))}" onclick="pay_cancel(this)">{$vo}</a>
                                		<elseif condition="$k eq 'delivery'"/>                                                 
                                			<a class="btn btn-primary margin" href="{:U('Order/delivery_info',array('order_id'=>$order['order_id']))}">{$vo}</a>
                                		<elseif condition="$k eq 'refund'"/>
                                			 
											<input class="btn btn-primary" type="button" onclick="selectGoods2({$order['order_id']})" value="退货申请"> 	
                                		<else/>
                                		<button class="btn btn-primary margin" onclick="ajax_submit_form('order-action','{:U('Admin/order/order_action',array('order_id'=>$order['order_id'],'type'=>$k))}');" type="button" id="confirm">
                                		{$vo}</button>
                                		</if>
                                	</foreach>                                
                                </div>
                            </td>
                        </div>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
-->
        <!--新订单列表 操作记录信息-->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title text-center">操作记录</h3>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <td class="text-center">操作者</td>
                        <td class="text-center">操作时间</td>
                        <td class="text-center">订单状态</td>
                        <td class="text-center">付款状态</td>
                        <td class="text-center">发货状态</td>
                        <td class="text-center">描述</td>
                        <td class="text-center">备注</td>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="action_log" id="log">
                        <tr>
                            <td class="text-center">{$log.action_user}({$log.user}-{$log.user_name})</td>
                            <td class="text-center">{$log.log_time|date='Y-m-d H:i:s',###}</td>
                            <td class="text-center">{$order_status[$log[order_status]]}</td>
                            <td class="text-center">{$pay_status[$log[pay_status]]}<if condition="$order['pay_code'] eq 'code'"><span style="color: red">(货到付款)</span></if></td>
                            <td class="text-center">{$shipping_status[$log[shipping_status]]}</td>
                            <td class="text-center">{$log.status_desc}</td>
                            <td class="text-center">{$log.action_note}</td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div>
          </div>
        </div>
	  </div>
    </div> 
   </section>
</div>
</body>
<script>
function pay_cancel(obj){
    var url =  $(obj).attr('data-url')+'/'+Math.random();
    layer.open({
        type: 2,
        title: '退款操作',
        shadeClose: true,
        shade: 0.8,
        area: ['45%', '50%'],
        content: url, 
    });
}
//取消付款
function pay_callback(s){
	if(s==1){
		layer.msg('操作成功', {icon: 1});
		layer.closeAll('iframe');
		location.href =	location.href;                
	}else{
		layer.msg('操作失败', {icon: 3});
		layer.closeAll('iframe');
		location.href =	location.href;                
	}
}

// 弹出退换货商品
function selectGoods2(order_id){
	var url = "/index.php?m=Admin&c=Order&a=get_order_goods&order_id="+order_id;
	layer.open({
		type: 2,
		title: '选择商品',
		shadeClose: true,
		shade: 0.8,
		area: ['60%', '60%'],
		content: url, 
	});
}    
// 申请退换货
function call_back(order_id,goods_id)
{
	var url = "/index.php?m=Admin&c=Order&a=add_return_goods&order_id="+order_id+"&goods_id="+goods_id;	
	location.href = url;
}

function edit_time(e,type){
    var value = $(e).val();
    var order_id = $(e).attr('rel');
    if(value){
        $.ajax({
            type : "POST",
            url:"/index.php/Admin/order/edit_ku_time",
            data : {val:value,type:type,order_id:order_id},// 你的formid
            success: function(data){
                layer.msg('修改成功', {icon: 1});
            }
        });
    }
}
</script>
</html>